package com.snail.snailvr.utils;


import com.dac.pushinfosession.ntv.pushInfoSession;

import java.util.Map;

/**
 * Created by MRKING on 2016/5/24.
 */
public class PushInfoUtil {
    private static volatile PushInfoUtil sPushInfoUtil;
    private static pushInfoSession sPushInfoSession;

    private PushInfoUtil(){}
    public static PushInfoUtil getInstance(){
        if(sPushInfoUtil == null){
            synchronized (PushInfoUtil.class){
                if(sPushInfoUtil == null){
                    sPushInfoUtil = new PushInfoUtil();
                    sPushInfoSession = new pushInfoSession();
                    sPushInfoSession.init();
                }
            }
        }
        return sPushInfoUtil;
    }

    /**
     * 反初始化，在app退出的时候调用
     */
    public void unInit(){
        sPushInfoSession.unInit();
        sPushInfoUtil = null;
        sPushInfoSession = null;
    }

    /**
     * 发送数据
     * @param infoMap
     */
    public void pushInfo(Map<String,String> infoMap){
        if (infoMap == null || infoMap.isEmpty())
            return;
        for (String key:infoMap.keySet()){
             sPushInfoSession.addInfo(key,infoMap.get(key));
        }
        sPushInfoSession.pushAddInfo();
    }
}
